<?php

namespace App\Http\Controllers\Contract;

use App\Helpers\ContractApiTrait;
use App\Helpers\ResponseData;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use App\Models\Contract\CarContract;
use Modules\Car\Entities\CarOrder;
use Illuminate\Support\Facades\Http;

class ContractTemplateController extends Controller
{
    use ResponseData, ContractApiTrait;

    //'templateId'=>'yDCDxUUndn7miqUJE1yYEGB0yQNH4OBw'
    public function templateInfo(Request $request){
        if(empty($request->template_id)){
            return $this->failed('合同id不能为空');
        }
        $data=[
            'agent'=>[
                'operator'=>[
                    'openId'=>'7e3b08fa-3069-4d95-9bb9-84bef1920b15',
                ],
            ],
            'templateId'=>$request->template_id
        ];
        $requestData=$this->getRequestData('DescribeTemplates',$data);
        $response=Http::post($this->getQizongApiUrl(),$requestData);
        $resData=$response->json();
        if(isset($resData['code']) && $resData['code']==0){
            return $this->success($resData);
        }
        $this->createContractErrorLog('查询合同模板失败',$resData,$request);
        return $this->failed($resData['msg']);
    }


}
